Skip to content

Potential fix for code scanning alert no. 5: Incomplete URL substring sanitization - #320

Open
Tatsat (Tats) Mishra 🐉 (Tatsinnit) wants to merge 1 commit into
mainfrom
alert-autofix-5
Open

Tatsat (Tats) Mishra 🐉 (Tatsinnit) wants to merge 1 commit into
mainfrom
alert-autofix-5

Conversation

@Tatsinnit

Copy link
Copy Markdown
Member

Potential fix for https://github.com/Azure/setup-helm/security/code-scanning/5

Use structured URL parsing and compare URL origin (or host/protocol) instead of raw string prefix checks.

Best fix in this file:

  • In src/run.test.ts, inside the test run() - resolve a major.minor version from the fallback mirror, replace:
    • const url = String(input)
    • if (url.startsWith(downloadBaseURL)) { ... }
  • With logic that:
    • Parses both input and downloadBaseURL using new URL(...)
    • Compares origin values (protocol + host + port) to decide if request targets the primary base host
    • Safely falls back if parsing fails (treat as non-primary)

This preserves functionality (fail primary, succeed fallback) while eliminating substring-based URL checks.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Tatsinnit
Tatsat (Tats) Mishra 🐉 (Tatsinnit) marked this pull request as ready for review November 29, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant